//
//  BN_ReportViewController.m
//  BabyNow
//
//  Created by 刘泽琛 on 14-7-15.
//  Copyright (c) 2014年 iMobile. All rights reserved.
//

#import "BN_ReportViewController.h"

@interface BN_ReportViewController ()

@end

@implementation BN_ReportViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"举报";
    [self joiningTogetherData];
    [self joiningTogetherUI];
}

- (void)joiningTogetherData {
    [self addObserver:self forKeyPath:@"selectedState" options:NSKeyValueObservingOptionNew context:NULL];
}

- (void)joiningTogetherUI {
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"houtui"] style:UIBarButtonItemStylePlain target:self action:@selector(backVctrl)];
    self.navigationItem.leftBarButtonItem = leftItem;
    _submitBtn.backgroundColor = APP_OBJECT_GREEN_COLOR;
    
    // 默认
    self.selectedState = 0;
}

- (IBAction)sexAction:(id)sender {
    self.selectedState = 0;
}

- (IBAction)infringementAction:(id)sender {
    self.selectedState = 1;
}

- (IBAction)sensitiveAction:(id)sender {
    self.selectedState = 2;
}

- (IBAction)submitAction:(id)sender {
    [self releaseResource];
    [LZCHINT title:@"提交成功，谢谢！" type:LZCSuccess duration:2 places:HINT_PLACES callBack:NULL];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
    NSInteger selectedState = [change[@"new"] integerValue];
    switch (selectedState) {
        case 0:
        {
            [_sexBtn setImage:[UIImage imageNamed:@"agreement_select"] forState:UIControlStateNormal];
            [_infringementBtn setImage:[UIImage imageNamed:@"agreement_unselect"] forState:UIControlStateNormal];
            [_sensitiveBtn setImage:[UIImage imageNamed:@"agreement_unselect"] forState:UIControlStateNormal];
        }
            break;
        case 1:
        {
            [_sexBtn setImage:[UIImage imageNamed:@"agreement_unselect"] forState:UIControlStateNormal];
            [_infringementBtn setImage:[UIImage imageNamed:@"agreement_select"] forState:UIControlStateNormal];
            [_sensitiveBtn setImage:[UIImage imageNamed:@"agreement_unselect"] forState:UIControlStateNormal];
        }
            break;
        case 2:
        {
            [_sexBtn setImage:[UIImage imageNamed:@"agreement_unselect"] forState:UIControlStateNormal];
            [_infringementBtn setImage:[UIImage imageNamed:@"agreement_unselect"] forState:UIControlStateNormal];
            [_sensitiveBtn setImage:[UIImage imageNamed:@"agreement_select"] forState:UIControlStateNormal];
        }
            break;
        default:
            break;
    }
}

- (void)releaseResource {
    [self removeObserver:self forKeyPath:@"selectedState" context:NULL];
}

- (void)backVctrl {
    [self releaseResource];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)dealloc
{
    NSLog(@"举报视图控制器释放...");
}

@end
